import Base = require("core/Base.class");
import Functions = require('core/Functions.module');
import SimpleLineSymbol = require('esri/symbols/SimpleLineSymbol');
import SimpleMarkerSymbol = require("esri/symbols/SimpleMarkerSymbol");
import Extent = require("esri/geometry/Extent");
import SimpleFillSymbol = require('esri/symbols/SimpleFillSymbol');
import Graphic = require('esri/graphic');
import Color = require('esri/Color');

// 定义点标志
export const MarkerSymbolHilight = new SimpleMarkerSymbol({
    "color": [, 255, 255],
    "size": 12,
    "xoffset": 0,
    "yoffset": 0,
    "style": "circle",
    "outline": {
        "color": [255, 0, 255],
        "width": 2,
        "style": "solid"
    }
});
// 定义线标志
export const LineSymbolHilight = new SimpleLineSymbol({
    "color": [0, 255, 255],
    "style": "solid",
    "width": 3
});

export const FillSymbolHilight = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
    new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 255, 255]), 3),
    new Color([0, 0, 0, 0.1])
);

/**
* (方法说明)用于halfpanel的缩放地图到几何图形
* @method (方法名)
* @for (所属类名)
* @param {(参数类型)} (参数名) (参数说明)
* @return {(返回值类型)} (返回值说明)
*/
export function zoom2MapHalf(geo) {
    var extent = geo.getExtent();
    var width = extent.xmax - extent.xmin;
    var height = extent.ymax - extent.ymin;
    extent.ymin = extent.ymin - height;
    height = extent.ymax - extent.ymin;
    var xmin = extent.xmin - width * 1 / 3;
    var xmax = extent.xmax + width * 1 / 3;
    var ymin = extent.ymin - height * 1 / 3;
    var ymax = extent.ymax + height * 1 / 3;
    var resultExtent = new Extent(xmin, ymin, xmax, ymax, this.map.spatialReference);
    this.AppX.runtimeConfig.map.setExtent(resultExtent);
}

export function zoom2Map(geo) {
    var extent = geo.getExtent();
    var xmin: number = extent.xmin;
    var xmax: number = extent.xmax;
    var ymin: number = extent.ymin;
    var ymax: number = extent.ymax;
    var width = xmax - xmin;
    var height = ymax - ymin;
    xmin = xmin - width / 2;
    xmax = xmax + width / 2;
    ymin = ymin - height / 2;
    ymax = ymax + height / 2;
    var resultExtent = new Extent(xmin, ymin, xmax, ymax, this.map.spatialReference);
    this.AppX.runtimeConfig.map.setExtent(resultExtent);
}